<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<title>文档列表 - 光年(Light Year Admin)后台管理系统模板</title>
<link rel="icon" th:href="@{/favicon.ico}" href="favicon.ico" type="image/ico">
<meta name="keywords" content="LightYear,光年,后台模板,后台管理系统,光年HTML模板">
<meta name="description" content="LightYear是一个基于Bootstrap v3.3.7的后台管理系统的HTML模板。">
<meta name="author" content="yinqi">
<link th:href="@{/css/bootstrap.min.css}" href="css/bootstrap.min.css" rel="stylesheet">
<link th:href="@{/css/materialdesignicons.min.css}" href="css/materialdesignicons.min.css" rel="stylesheet">
<link th:href="@{/css/style.min.css}" href="css/style.min.css" rel="stylesheet">
</head>
  
<body>
<div class="lyear-layout-web">
  <div class="lyear-layout-container">
    <!--左侧导航-->
    <aside th:replace="~{main :: left}" class="lyear-layout-sidebar">
       
      <!-- logo -->
      <div id="logo" class="sidebar-header">
        <a href="index.html"><img src="images/logo-sidebar.png" title="LightYear" alt="LightYear" /></a>
      </div>
      <div class="lyear-layout-sidebar-scroll">
        
        <nav class="sidebar-main">
          <ul class="nav nav-drawer">
            <li class="nav-item"> <a href="index.html"><i class="mdi mdi-home"></i> 后台首页</a> </li>
            <li class="nav-item nav-item-has-subnav">
              <a href="javascript:void(0)"><i class="mdi mdi-palette"></i> UI 元素</a>
              <ul class="nav nav-subnav">
                <li> <a href="lyear_ui_buttons.html">按钮</a> </li>
                <li> <a href="lyear_ui_cards.html">卡片</a> </li>
                <li> <a href="lyear_ui_grid.html">格栅</a> </li>
                <li> <a href="lyear_ui_icons.html">图标</a> </li>
                <li> <a href="lyear_ui_tables.html">表格</a> </li>
                <li> <a href="lyear_ui_modals.html">模态框</a> </li>
                <li> <a href="lyear_ui_tooltips_popover.html">提示 / 弹出框</a> </li>
                <li> <a href="lyear_ui_alerts.html">警告框</a> </li>
                <li> <a href="lyear_ui_pagination.html">分页</a> </li>
                <li> <a href="lyear_ui_progress.html">进度条</a> </li>
                <li> <a href="lyear_ui_tabs.html">标签页</a> </li>
                <li> <a href="lyear_ui_typography.html">排版</a> </li>
                <li> <a href="lyear_ui_step.html">步骤</a> </li>
                <li> <a href="lyear_ui_other.html">其他</a> </li>
              </ul>
            </li>
            <li class="nav-item nav-item-has-subnav">
              <a href="javascript:void(0)"><i class="mdi mdi-format-align-justify"></i> 表单</a>
              <ul class="nav nav-subnav">
                <li> <a href="lyear_forms_elements.html">基本元素</a> </li>
                <li> <a href="lyear_forms_radio.html">单选框</a> </li>
                <li> <a href="lyear_forms_checkbox.html">复选框</a> </li>
                <li> <a href="lyear_forms_switch.html">开关</a> </li>
              </ul>
            </li>
            <li class="nav-item nav-item-has-subnav active open">
              <a href="javascript:void(0)"><i class="mdi mdi-file-outline"></i> 示例页面</a>
              <ul class="nav nav-subnav">
                <li class="active"> <a href="lyear_pages_doc.html">文档列表</a> </li>
                <li> <a href="lyear_pages_gallery.html">图库列表</a> </li>
                <li> <a href="lyear_pages_config.html">网站配置</a> </li>
                <li> <a href="lyear_pages_rabc.html">设置权限</a> </li>
                <li> <a href="lyear_pages_add_doc.html">新增文档</a> </li>
                <li> <a href="lyear_pages_guide.html">表单向导</a> </li>
                <li> <a href="lyear_pages_login.html">登录页面</a> </li>
                <li> <a href="lyear_pages_login_2.html">登录页面2</a> </li>
                <li> <a href="lyear_pages_login_3.html">登录页面3</a> </li>
                <li> <a href="lyear_pages_login_4.html">登录页面4</a> </li>
                <li> <a href="lyear_pages_error.html">错误页面</a> </li>
              </ul>
            </li>
            <li class="nav-item nav-item-has-subnav">
              <a href="javascript:void(0)"><i class="mdi mdi-language-javascript"></i> JS 插件</a>
              <ul class="nav nav-subnav">
                <li> <a href="lyear_js_datepicker.html">日期选取器</a> </li>
                <li> <a href="lyear_js_sliders.html">滑块</a> </li>
                <li> <a href="lyear_js_colorpicker.html">选色器</a> </li>
                <li> <a href="lyear_js_chartjs.html">Chart.js</a> </li>
                <li> <a href="lyear_js_jconfirm.html">对话框</a> </li>
                <li> <a href="lyear_js_tags_input.html">标签插件</a> </li>
                <li> <a href="lyear_js_notify.html">通知消息</a> </li>
              </ul>
            </li>
          </ul>
        </nav>
        
        <div class="sidebar-footer">
          <p class="copyright">Copyright &copy; 2019. <a target="_blank" href="http://lyear.itshubao.com">IT书包</a> All rights reserved.</p>
        </div>
      </div>
      
    </aside>
    <!--End 左侧导航-->
    
    <!--头部信息-->
    <header th:replace="~{main :: top('数据列表 - 管理员数据')}" class="lyear-layout-header">
      
      <nav class="navbar navbar-default">
        <div class="topbar">
          
          <div class="topbar-left">
            <div class="lyear-aside-toggler">
              <span class="lyear-toggler-bar"></span>
              <span class="lyear-toggler-bar"></span>
              <span class="lyear-toggler-bar"></span>
            </div>
            <span class="navbar-page-title"> 示例页面 - 文档列表 </span>
          </div>
          
          <ul class="topbar-right">
            <li class="dropdown dropdown-profile">
              <a href="javascript:void(0)" data-toggle="dropdown">
                <img class="img-avatar img-avatar-48 m-r-10" src="images/users/avatar.jpg" alt="笔下光年" />
                <span>笔下光年 <span class="caret"></span></span>
              </a>
              <ul class="dropdown-menu dropdown-menu-right">
                <li> <a href="lyear_pages_profile.html"><i class="mdi mdi-account"></i> 个人信息</a> </li>
                <li> <a href="lyear_pages_edit_pwd.html"><i class="mdi mdi-lock-outline"></i> 修改密码</a> </li>
                <li> <a href="javascript:void(0)"><i class="mdi mdi-delete"></i> 清空缓存</a></li>
                <li class="divider"></li>
                <li> <a href="lyear_pages_login.html"><i class="mdi mdi-logout-variant"></i> 退出登录</a> </li>
              </ul>
            </li>
            <!--切换主题配色-->
		    <li class="dropdown dropdown-skin">
			  <span data-toggle="dropdown" class="icon-palette"><i class="mdi mdi-palette"></i></span>
			  <ul class="dropdown-menu dropdown-menu-right" data-stopPropagation="true">
                <li class="drop-title"><p>主题</p></li>
                <li class="drop-skin-li clearfix">
                  <span class="inverse">
                    <input type="radio" name="site_theme" value="default" id="site_theme_1" checked>
                    <label for="site_theme_1"></label>
                  </span>
                  <span>
                    <input type="radio" name="site_theme" value="dark" id="site_theme_2">
                    <label for="site_theme_2"></label>
                  </span>
                  <span>
                    <input type="radio" name="site_theme" value="translucent" id="site_theme_3">
                    <label for="site_theme_3"></label>
                  </span>
                </li>
			    <li class="drop-title"><p>LOGO</p></li>
				<li class="drop-skin-li clearfix">
                  <span class="inverse">
                    <input type="radio" name="logo_bg" value="default" id="logo_bg_1" checked>
                    <label for="logo_bg_1"></label>
                  </span>
                  <span>
                    <input type="radio" name="logo_bg" value="color_2" id="logo_bg_2">
                    <label for="logo_bg_2"></label>
                  </span>
                  <span>
                    <input type="radio" name="logo_bg" value="color_3" id="logo_bg_3">
                    <label for="logo_bg_3"></label>
                  </span>
                  <span>
                    <input type="radio" name="logo_bg" value="color_4" id="logo_bg_4">
                    <label for="logo_bg_4"></label>
                  </span>
                  <span>
                    <input type="radio" name="logo_bg" value="color_5" id="logo_bg_5">
                    <label for="logo_bg_5"></label>
                  </span>
                  <span>
                    <input type="radio" name="logo_bg" value="color_6" id="logo_bg_6">
                    <label for="logo_bg_6"></label>
                  </span>
                  <span>
                    <input type="radio" name="logo_bg" value="color_7" id="logo_bg_7">
                    <label for="logo_bg_7"></label>
                  </span>
                  <span>
                    <input type="radio" name="logo_bg" value="color_8" id="logo_bg_8">
                    <label for="logo_bg_8"></label>
                  </span>
				</li>
				<li class="drop-title"><p>头部</p></li>
				<li class="drop-skin-li clearfix">
                  <span class="inverse">
                    <input type="radio" name="header_bg" value="default" id="header_bg_1" checked>
                    <label for="header_bg_1"></label>                      
                  </span>                                                    
                  <span>                                                     
                    <input type="radio" name="header_bg" value="color_2" id="header_bg_2">
                    <label for="header_bg_2"></label>                      
                  </span>                                                    
                  <span>                                                     
                    <input type="radio" name="header_bg" value="color_3" id="header_bg_3">
                    <label for="header_bg_3"></label>
                  </span>
                  <span>
                    <input type="radio" name="header_bg" value="color_4" id="header_bg_4">
                    <label for="header_bg_4"></label>                      
                  </span>                                                    
                  <span>                                                     
                    <input type="radio" name="header_bg" value="color_5" id="header_bg_5">
                    <label for="header_bg_5"></label>                      
                  </span>                                                    
                  <span>                                                     
                    <input type="radio" name="header_bg" value="color_6" id="header_bg_6">
                    <label for="header_bg_6"></label>                      
                  </span>                                                    
                  <span>                                                     
                    <input type="radio" name="header_bg" value="color_7" id="header_bg_7">
                    <label for="header_bg_7"></label>
                  </span>
                  <span>
                    <input type="radio" name="header_bg" value="color_8" id="header_bg_8">
                    <label for="header_bg_8"></label>
                  </span>
				</li>
				<li class="drop-title"><p>侧边栏</p></li>
				<li class="drop-skin-li clearfix">
                  <span class="inverse">
                    <input type="radio" name="sidebar_bg" value="default" id="sidebar_bg_1" checked>
                    <label for="sidebar_bg_1"></label>
                  </span>
                  <span>
                    <input type="radio" name="sidebar_bg" value="color_2" id="sidebar_bg_2">
                    <label for="sidebar_bg_2"></label>
                  </span>
                  <span>
                    <input type="radio" name="sidebar_bg" value="color_3" id="sidebar_bg_3">
                    <label for="sidebar_bg_3"></label>
                  </span>
                  <span>
                    <input type="radio" name="sidebar_bg" value="color_4" id="sidebar_bg_4">
                    <label for="sidebar_bg_4"></label>
                  </span>
                  <span>
                    <input type="radio" name="sidebar_bg" value="color_5" id="sidebar_bg_5">
                    <label for="sidebar_bg_5"></label>
                  </span>
                  <span>
                    <input type="radio" name="sidebar_bg" value="color_6" id="sidebar_bg_6">
                    <label for="sidebar_bg_6"></label>
                  </span>
                  <span>
                    <input type="radio" name="sidebar_bg" value="color_7" id="sidebar_bg_7">
                    <label for="sidebar_bg_7"></label>
                  </span>
                  <span>
                    <input type="radio" name="sidebar_bg" value="color_8" id="sidebar_bg_8">
                    <label for="sidebar_bg_8"></label>
                  </span>
				</li>
			  </ul>
			</li>
            <!--切换主题配色-->
          </ul>
          
        </div>
      </nav>
      
    </header>
    <!--End 头部信息-->
    
    <!--页面主要内容-->
    <main class="lyear-layout-content">
      <div class="container-fluid">
        <div class="row">
          <div class="col-lg-12">
            <div class="card">
              <!-- 工具栏 -->
              <div class="card-toolbar clearfix">
                <!-- 关键字搜索框 -->
                <form class="pull-right search-bar" role="form">
                  <div class="input-group">
                    <div class="input-group-btn">
                      <button class="btn btn-default dropdown-toggle" id="search-btn" data-toggle="dropdown" type="button" aria-haspopup="true" aria-expanded="false">
                      关键字：
                      </button>
                    </div>
                    <input type="text" style="width: 130px" class="form-control" th:value="${keywords}" value="" name="keywords" placeholder="请输入关键字">
                    <button onclick="search();" class="btn btn-default dropdown-toggle" id="search-btn2" data-toggle="dropdown" type="button" aria-haspopup="true" aria-expanded="false">
                      搜 索
                    </button>
                  </div>
                </form>
                <!-- 功能按钮 -->
                <div class="toolbar-btn-action">
                  <a class="btn btn-primary m-r-5" th:href="@{/admin/manager/add}" href="#!"><i class="mdi mdi-plus"></i> 新增</a>
                  <a class="btn btn-success m-r-5" th:attr="_href=@{/admin/manager/editState/1}" href="javascript:void(0);" onclick="editState(this,'1');" ><i class="mdi mdi-check"></i> 启用</a>
                  <a class="btn btn-warning m-r-5" th:attr="_href=@{/admin/manager/editState/0}" href="javascript:void(0);" onclick="editState(this,'0');" ><i class="mdi mdi-block-helper"></i> 禁用</a>
                  <a class="btn btn-danger" th:attr="_href=@{/admin/manager}" href="javascript:void(0);" onclick="del(this);"><i class="mdi mdi-window-close"></i> 删除</a>
                </div>
              </div>
              <!-- 页面主题表格 -->
              <div class="card-body">
                <!-- 数据表格 -->
                <div class="table-responsive">
                  <table class="table table-bordered table-striped table-vcenter table-hover">
                    <thead>
                      <tr>
                        <th style="width: 50px;">
                          <label class="lyear-checkbox checkbox-primary">
                            <input type="checkbox" id="check-all"><span></span>
                          </label>
                        </th>
                        <th style="width: 100px;">序号</th>
                        <th>昵称</th>
                        <th>姓名</th>
                        <th style="width: 100px;">联系方式</th>
                        <th style="width: 100px;">邮箱</th>
                        <th style="width: 100px;">状态</th>
                        <th style="width: 150px;">操作</th>
                      </tr>
                    </thead>
                    <tbody>
                      <tr th:each="m : ${result.data.list}">
                        <td>
                          <label class="lyear-checkbox checkbox-primary">
                            <input type="checkbox" th:value="${m.managerId}" name="managerId" value="1"><span></span>
                          </label>
                        </td>
                        <td th:text="${mStat.count}">1</td>
                        <td th:utext="${m.managerNickname}">第01章 天涯思君不可忘</td>
                        <td th:utext="${m.managerName}">《倚天屠龙记》</td>
                        <td th:utext="${m.managerTel}">金庸</td>
                        <td th:utext="${m.managerEmail}">xxxxx@qq.com</td>
                        <td th:utext="${m.managerState != null} ? ${m.managerState.dicContext} : ''">启用</td>
                        <td>
                          <div class="btn-group">
                            <a class="btn btn-xs btn-default" th:href="@{/admin/manager/{id}(id=${m.managerId})}" href="#!" title="编辑" data-toggle="tooltip"><i class="mdi mdi-pencil"></i></a>
                            <a class="btn btn-xs btn-default" th:href="@{'/admin/dictionary/'}" href="#!" title="查看" data-toggle="tooltip"><i class="mdi mdi-eye"></i></a>
                            <a class="btn btn-xs btn-default" th:onclick="|deleteConfirm('@{/admin/manager/{id}(id=${m.managerId}) }',this);|"  title="删除" data-toggle="tooltip"><i class="mdi mdi-window-close"></i></a>
                          </div>
                        </td>
                      </tr>
                    </tbody>
                  </table>
                </div>
                <!-- 分页菜单栏 -->
                <ul class="pagination">
                  <li><a href="javascript:void(0);" th:onclick="topage(1)">首页</a></li>
                  <li th:class="${result.data.isFirstPage} ? 'disabled' : ''" >
                    <a  href="javascript:void(0);" th:onclick="${result.data.isFirstPage}? '' :|topage(${result.data.prePage})|">上一页</a>
                  </li>
                  <li th:class="${result.data.isLastPage} ? 'disabled' : ''" >
                    <a href="javascript:void(0);" th:onclick="${result.data.isLastPage} ? '' : |topage(${result.data.nextPage})|">下一页</a>
                  </li>
                  <li><a href="javascript:void(0);" th:onclick="|topage(${result.data.pages})|">尾页</a></li>
                  <li> 当前第 [[${result.data.pageNum}]] 页，共 [[${result.data.pages}]] 页，共 [[${result.data.total}]] 条数据 </li>
                </ul>
              </div>
            </div>
          </div>
        </div>
      </div>
    </main>
    <!--End 页面主要内容-->
  </div>
</div>

<script type="text/javascript" th:src="@{/js/jquery.min.js}" src="js/jquery.min.js"></script>
<script type="text/javascript" th:src="@{/js/bootstrap.min.js}" src="js/bootstrap.min.js"></script>
<script type="text/javascript" th:src="@{/js/perfect-scrollbar.min.js}" src="js/perfect-scrollbar.min.js"></script>
<script type="text/javascript" th:src="@{/js/main.min.js}" src="js/main.min.js"></script>
<script type="text/javascript" th:inline="javascript">
  /* 页面加载完成回调函数 */
$(function(){

    $('.search-bar .dropdown-menu a').click(function() {
        var field = $(this).data('field') || '';
        $('#search-field').val(field);
        $('#search-btn').html($(this).text() + ' <span class="caret"></span>');
    });

});
  /*
    删除确认函数
   */
  function deleteConfirm(v , t){
    // console.log($(t).parent("tr"))
    var boo = confirm("是否确定删除改数据？");
    if(boo){
      $.ajax({
        type: "DELETE",
        url: v ,
        success:function (data){
            if(data.code == 200){
                alert(data.message);
                $(t).parents("tr").remove();
            }
        },
        dataType: "json"
      });
    }
  }

  /**
   * 批量删除函数
   */
  function del(t){
      // 获取所有页面要删除的数据集合，并判断用户至少选择了一条数据
      var managerIds = $("input[name=managerId]");
      var boo = false;
      managerIds.each(function (){
          if(this.checked){
              boo = true;
          }
      });
      if(boo){
          var con = confirm("是否确认删除多条数据？");
          if(con){
              $.ajax({
                type: "delete",
                url:$(t).attr("_href"),
                data:managerIds.serialize(),
                success:function (data){
                    if(data.code == 200){
                        alert(data.message);
                        // 遍历所有的被删除元素数据行，并从页面中删除
                        managerIds.each(function (){
                            if(this.checked){
                              $(this).parents("tr").remove();
                            }
                        });
                    }else{
                        // 删除失败的处理方式。。。
                    }
                },
                dataType: "json"
              });
          }
      }else{
          alert("请至少选择一条要删除的数据！");
      }

  }

  /* 管理员启用、禁用函数 */
  function editState(t , state){
      // 获取所有页面要删除的数据集合，并判断用户至少选择了一条数据
      var managerIds = $("input[name=managerId]");
      var boo = false;
      managerIds.each(function (){
        if(this.checked){
          boo = true;
        }
      });
      if(boo){
        var con = confirm("是否改变这些管理员状态？");
        if(con){
          $.ajax({
            type: "put",
            url:$(t).attr("_href"),
            data:managerIds.serialize(),
            success:function (data){
              if(data.code == 200){
                  alert(data.message);
                  // 刷新页面显示最新数据
                  window.history.go(0);
              }else{
                // 删除失败的处理方式。。。
              }
            },
            dataType: "json"
          });
        }
      }else{
        alert("请至少选择一条要改变状态的数据！");
      }
  }

  function search(){
      // 获取关键字输入框的值，为其序列化，
      var keywords = $("input[name=keywords]").serialize();
      // 获取当前路径 URL 然后为路径 url 拼接关键字参数并重新提交
      window.location = window.location.pathname + "?" + keywords;
  }

  function topage(num){
    // 获取关键字输入框的值，为其序列化，
    var keywords = $("input[name=keywords]").serialize();
    // 获取当前路径 URL 然后为路径 url 拼接关键字参数并重新提交
    window.location = window.location.pathname + "?" + keywords + "&pageNum=" + num;
  }
</script>
</body>
</html>